package com.hmdp.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RedissonConfig {

    @Bean
    public  RedissonClient redissonClient() {
        Config config = new Config();
        // 设置Redis服务器地址
        config.useSingleServer()
                .setAddress("redis://192.168.8.135:6379")
                .setPassword("123321")
                // 增加命令超时时间（默认3000毫秒）
                .setTimeout(5000)
                // 增加连接超时时间
                .setConnectTimeout(5000)
                // 增加重试次数
                .setRetryAttempts(3)
                // 增加重试间隔时间
                .setRetryInterval(1500)
                // 优化连接池配置
                .setConnectionPoolSize(64)
                .setConnectionMinimumIdleSize(10)
                .setRetryInterval(3000)
                .setRetryAttempts(3);
        return Redisson.create(config);
    }
}